from selenium import webdriver


class InitDriver(object):

    def init_driver(self, dr_name, ex_time=10):
        '''
        初始化浏览器驱动
        :param dr_name: 需要使用的浏览器
        :param ex_time: 等待元素加载时间
        :return: 返回浏览器driver
        '''
        dr_name = str(dr_name).strip().capitalize()
        if dr_name == "Chrome":
            driver = webdriver.Chrome()
        elif dr_name == "Edge":
            driver = webdriver.Edge()
        elif dr_name == "FireFox":
            driver = webdriver.Firefox()
        else:
            driver = webdriver.Ie()

        driver.maximize_window()
        driver.implicitly_wait(ex_time)
        return driver
